package com.wzcl.app.dao.repository;

import com.wzcl.app.dao.model.TaskEvaluateScore;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import java.beans.Transient;

public interface TaskEvaluateScoreRepository extends JpaRepository<TaskEvaluateScore, Integer> {
    @Transient
    @Modifying
    @Query(value = "delete from TaskEvaluateScore tes where tes.taskId = ?1 and tes.phone = ?2")
    void deleteByTaskId(Integer taskId, String phone);

    //获取当前用户的任务获得的评分
    @Query(value = "select tes.star from TaskEvaluateScore tes where tes.taskId = ?1 and tes.phone = ?2")
    Integer findStarByTaskId(Integer taskId, String phone);

    //查询当前任务完成情况
    @Query(value = "select tes from TaskEvaluateScore tes where tes.taskId = ?1 and tes.phone = ?2")
    TaskEvaluateScore findByTaskId(Integer taskId, String phone);
}
